home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Libraries / C Internet Config / CInternetConfig ƒ / main.cp < prev   
Encoding:
Text File  |  1995-12-07  |  1.0 KB  |  48 lines  |  [TEXT/SPM ]

  1. /*
  2.     main.cp
  3.     
  4.     This is a sample program based upon the "IC Hello Cruel World" program
  5.     which is intended to show the simplest IC aware C++ program using
  6.     the CInternetConfig class.  It simply outputs the Real Name preference.
  7. */
  8.  
  9. #include <stdlib.h>
  10. #include <iostream.h>
  11.  
  12. #include "IC Types.h"
  13. #include "IC Keys.h"
  14.  
  15. #include "CInternetConfig.hpp"
  16.  
  17. int main(){
  18.     CInternetConfig* ic;
  19.     Str255 str;
  20.     long str_size;
  21.     ICAttr attr;
  22.     
  23.     cout<<"Hello Cruel World C++ Test" << endl;
  24.     
  25.     ic=new CInternetConfig('????');
  26.     
  27.     if (ic->GetLastError()==noErr){
  28.         if (ic->FindConfigFile(0,NULL)==noErr){
  29.             Str255 temp=kICRealName;
  30.             
  31.             str_size=sizeof(Str255);
  32.             
  33.             if (ic->GetPref(temp,&attr,(Ptr)str,&str_size)==noErr){
  34.                 // convert pascal to c string
  35.                 str[str[0]+1]=0;
  36.                 cout << "Real name is " << ((char*)&(str[1]))<< endl;
  37.             } else
  38.                 cout << "CInternetConfig::GetPref Error" << endl;
  39.         } else
  40.             cout << "CInternetConfig::FindConfigFile error" << endl;
  41.         
  42.         delete ic;
  43.     } else
  44.         cout << "new CInternetConfig error" << endl;
  45.     
  46.     return 0;
  47. }
  48.